package keter.combofs;

import keter.combofs.api.s3.ComboS3;
import keter.combofs.api.adapters.ComboFsS3Adapter;
import keter.combofs.config.S3Config;
import keter.combofs.id.IdMaker;
import keter.combofs.id.impl.SequenceIdImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 初始化配置
 */
@Configuration
public class ComboFSAutoConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(ComboFSAutoConfiguration.class);

    @Bean
    @ConditionalOnMissingBean
    public ComboS3 initComboS3(){
        return new ComboFsS3Adapter();
    }

    @Bean
    @ConditionalOnMissingBean
    public S3Config initS3Client() {
        return new S3Config();
    }

    @Bean
    @ConditionalOnMissingBean
    public IdMaker initSequence() {
        logger.info("初始化默认的ID生成策略...");
        return new SequenceIdImpl(1);
    }
}
